package org.bitterorange.flansmodslain.models;

import com.flansmod.common.mob.EntitySoldier;
import com.flansmod.common.mob.api.SoldierAPI;
import net.minecraft.server.v1_7_R4.Entity;
import org.bukkit.Bukkit;
import org.bukkit.Location;

/**
 * AI实体包装器，用于跟Bukkit插件交互
 */
public class EntitySoldierWrapper {
    int entityId;
    String name;
    String faction;
    String country;
    String heldItemShortName;
    Entity vehicle;
    int health;
    Location location;
    short gunScope;
    short gunBarrel;
    short gunGadget;
    short gunGrip;

    public EntitySoldierWrapper(EntitySoldier entity) {
        this.entityId = SoldierAPI.getEntityId(entity);
        this.name = entity.name;
        this.faction = entity.faction.name();
        this.country = SoldierAPI.getSoldierTeamName(entity);
        this.heldItemShortName = "FLANSMOD_" + SoldierAPI.getHeldItemUnlocalizedName(entity).substring(5).toUpperCase();
        this.vehicle = (Entity) SoldierAPI.getVehicle(entity);
        this.health = SoldierAPI.getHealth(entity);
        this.location = new Location(Bukkit.getWorld(SoldierAPI.getWorldObjName(entity)), SoldierAPI.getPosX(entity), SoldierAPI.getPosY(entity), SoldierAPI.getPosZ(entity));
        this.gunScope = SoldierAPI.getHeldGunAttachmentId(entity, "scope");
        this.gunBarrel = SoldierAPI.getHeldGunAttachmentId(entity, "barrel");
        this.gunGadget = SoldierAPI.getHeldGunAttachmentId(entity, "gadget");
        this.gunGrip = SoldierAPI.getHeldGunAttachmentId(entity, "grip");
    }

    public int getEntityId() {
        return entityId;
    }

    public void setEntityId(int entityId) {
        this.entityId = entityId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFaction() {
        return faction;
    }

    public void setFaction(String faction) {
        this.faction = faction;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getHeldItemShortName() {
        return heldItemShortName;
    }

    public void setHeldItemShortName(String heldItemShortName) {
        this.heldItemShortName = heldItemShortName;
    }

    public Entity getVehicle() {
        return vehicle;
    }

    public void setVehicle(Entity vehicle) {
        this.vehicle = vehicle;
    }

    public int getHealth() {
        return health;
    }

    public void setHealth(int health) {
        this.health = health;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }



    @Override
    public String toString() {
        return "EntitySoldierWrapper{" +
                "entityId=" + entityId +
                ", name='" + name + '\'' +
                ", faction='" + faction + '\'' +
                ", country='" + country + '\'' +
                ", heldItemShortName='" + heldItemShortName + '\'' +
                ", vehicle=" + vehicle +
                ", health=" + health +
                ", location=" + location +
                ", gunScope='" + gunScope + '\'' +
                ", gunBarrel='" + gunBarrel + '\'' +
                ", gunGadget='" + gunGadget + '\'' +
                ", gunGrip='" + gunGrip + '\'' +
                '}';
    }

    public short getGunScope() {
        return gunScope;
    }

    public void setGunScope(short gunScope) {
        this.gunScope = gunScope;
    }

    public short getGunBarrel() {
        return gunBarrel;
    }

    public void setGunBarrel(short gunBarrel) {
        this.gunBarrel = gunBarrel;
    }

    public short getGunGadget() {
        return gunGadget;
    }

    public void setGunGadget(short gunGadget) {
        this.gunGadget = gunGadget;
    }

    public short getGunGrip() {
        return gunGrip;
    }

    public void setGunGrip(short gunGrip) {
        this.gunGrip = gunGrip;
    }
}
